package org.springcloud.wisdom.spring_02_classroom.student.sschedule.controller;

import org.springcloud.wisdom.spring_02_classroom.bean.BaseController;
import org.springcloud.wisdom.spring_02_classroom.bean.ResponseData;
import org.springcloud.wisdom.spring_02_classroom.student.sschedule.service.StudentScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/select")
public class StudentScheduleController extends BaseController {
    @Autowired
    private StudentScheduleService studentScheduleService;

    //学生查看自己名下的课程
    @GetMapping("/selfcourse")
    public ResponseData<Object> getCoursesByTeacherId(String sid) {
        return returnObject(studentScheduleService.findCoursesByTid(sid));
    }

    //学生查看所属课程的学生
    @GetMapping("/classmates")
    public ResponseData<Object> getStudentsByTid(String cid) {
        return returnObject(studentScheduleService.getStudentsByTid(cid));
    }

    //历史课程
    @RequestMapping("/all")
    public ResponseData<Object> getPage(@RequestParam("pageNum") int pageNum,
                                        @RequestParam("pageSize") int pageSize,
                                        @RequestParam(value = "sid",required = false) String sid){
        return returnObject(studentScheduleService.getcoursehistory(pageNum,pageSize,sid));
    }
}
